var html = '<div id="meetqy_vipBox" style="width:100px;height: 40px;border: 1px solid red;bottom: 0;right: 0;position: fixed;z-index: 9999999;background:#FF6600;line-height: 40px;color: #fff;font-size: 18px;text-align: center;cursor: pointer;">一键看视频</div>';
document.body.innerHTML += html;

var vipbox = document.getElementById('meetqy_vipBox');
var arr_url = getCookie('video_url');
var vip_url = getCookie('vip_url');
if(!arr_url) arr_url = geturl();
if(!vip_url) vip_url = get_vipurl();

vipbox.onclick = function() {
    typeof arr_url != 'object' && (arr_url = arr_url.split('\n'));
    var now_url = window.location.href;
    var open_url = vip_url + now_url;
    window.open(arr_url[rd(0, arr_url.length)]);
    window.open(open_url);
};

//设置cookie
function setCookie(name,value,day) {
    var Days = day;
    var exp = new Date();
    exp.setTime(exp.getTime() + Days * 24 * 60 * 60 * 1000);
    document.cookie = name + "=" + escape(value) + ";expires=" + exp.toGMTString();
}

//获取cookie
function getCookie(name) {
    var arr, reg = new RegExp("(^| )" + name + "=([^;]*)(;|$)");
    if (arr = document.cookie.match(reg))
        return unescape(arr[2]);
    else
        return null;
}

//随机数
function rd(n,m){
    var c = m-n+1;
    return Math.floor(Math.random() * c + n);
}

//获取url
function geturl() {
    $.get('https://www.meetqy.com/other/video_vip/geturl', function (data) {
        if (data.status == 200) {
            setCookie('video_url', data.data, 3);
        } else {
            setCookie('video_url', 'https://www.meetqy.com', 1);
        }
    });
}

function get_vipurl() {
    $.get('https://www.meetqy.com/other/video_vip/vip_url', function (data) {
		setCookie('vip_url',data.data,3);
    });
}

